﻿Public Class FormNGReason
    Public usr As String
    Public sys_id As String
    Public oper_type As String
    Public procedure_No As Integer
    Dim objReasonMst As New clsReasonMst
    Dim objGtProcedureOperatedNgDetails As New clsGtProcedureOperatedNgDetails

    Private Sub FormNGReason_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        If oper_type.Equals("0") Then
            objReasonMst.setMstChkList(chkNg_Reason, "gjb", procedure_No)
        Else
            objReasonMst.setMstChkList(chkNg_Reason, "flb", procedure_No)
        End If
    End Sub

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        Dim chklstChecked As Boolean = False
        For i As Integer = 0 To chkNg_Reason.Items.Count - 1
            If chkNg_Reason.Items(i).CheckState = CheckState.Checked Then
                chklstChecked = True
            End If
        Next
        If chklstChecked = False Then
            MsgBox("请选择不合格原因！")
            chkNg_Reason.Select()
            Exit Sub
        End If
        Dim ng_reason As String = String.Empty
        For i As Integer = 0 To chkNg_Reason.Items.Count - 1
            If chkNg_Reason.Items(i).CheckState = CheckState.Checked Then
                ng_reason &= chkNg_Reason.Items(i).Value & "/"
            End If
        Next
        ng_reason = ng_reason.Substring(0, ng_reason.Length - 1)
        Dim rtn As Integer = objGtProcedureOperatedNgDetails.save(ng_reason, sys_id)
        If rtn <> -2 Then
            MsgBox("保存成功")
            CType(Owner, FormCheck).setDgvNgData()
            Close()
        Else
            MsgBox("保存失败")
        End If
    End Sub
End Class